package com.octopus.kernal.service;

import java.util.Locale;
import java.util.ResourceBundle;

public class ConfigService {
	
	private static ConfigService configService;
	
	private ConfigService(){
		
	}
	
	public synchronized static ConfigService getInstance(){
		if(configService == null)
			configService = new ConfigService();
		return configService;
	}
	
	public String getProperty(String key){
		return this.getProperty(null, key);
	}
	
	public String getProperty(String configFile, String key){
		ResourceBundle configuation = ResourceBundle.getBundle(null==configFile?"configuration":configFile, Locale.getDefault());
		String value = configuation.getString(key);
		return value;
	}
	
	public String[] getProperties(String key){
		return this.getProperties(null, key);
	}
	
	public String[] getProperties(String configFile, String key){
		ResourceBundle configuation = ResourceBundle.getBundle(null==configFile?"configuration":configFile, Locale.getDefault());
		String value = configuation.getString(key);
		return value.split(",");
	}

}
